package com.example.demo.auth;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by linlg on 2016/7/17.
 */
public class AuthInterceptorAdapter extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        if (request.getRequestURI().contains("v0.1/user/action/register") || request.getRequestURI().contains("v0.1/user/action/login")) {
//            return true;
//        }
//        String token = request.getHeader("Authorization");
//        if (StringUtils.isEmpty(token)) {
//            throw new RuntimeException(MessageFormat.format(Constant.ERROR_FORMAT, 401, "权限不足"));
//        }
        return true;
    }


//    @Override
//    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
//        System.out.println("afterCompletion");
//    }
}
